package life.huangzhi.community.community.controller;

import life.huangzhi.community.community.dto.PaginationDTO;
import life.huangzhi.community.community.dto.QuestionDTO;
import life.huangzhi.community.community.mapper.QuestionMapper;
import life.huangzhi.community.community.mapper.UserMapper;
import life.huangzhi.community.community.model.Question;
import life.huangzhi.community.community.model.User;
import life.huangzhi.community.community.service.QuestionService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @author Administrator
 * @date 2019/11/24 21:23
 */
@Controller
public class IndexController {


    @Resource
    private QuestionService questionService;
    @GetMapping("/")
    public String index(HttpServletRequest request,
                        Model model,
                        @RequestParam(name="page",defaultValue ="1") Integer page,
                        @RequestParam(name = "size",defaultValue ="5") Integer pageSize){

        //查询提问数据
        PaginationDTO paginationDTO =questionService.queryQuestion(page,pageSize);
        model.addAttribute("pagination",paginationDTO);
        return "index";
    }
}
